#!/bin/bash
#
# getdocker netip  脚本 2016-09-01
#
netIp=''
if [[ -f "/usr/local/etc/netIp" ]]; then
	netIp=`cat /usr/local/etc/netIp`
fi
if [[ ! -z "$netIp" ]]; then
	read -p "netIp is $netIp? y/n " confirm
	if [[ $confirm != 'y' ]]; then
		netIp=''
	fi

fi
while [[ -z $netIp ]]; do
        read -p "Please input the kubernetes netIp [eg: 172.16.0.21]: " netIp
        if [[ $netIp =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
            echo "netIp is :$netIp"
            echo "$netIp" > /usr/local/etc/netIp
        else
            echo "error input ip, please try again."
            netIp=''
        fi
done
